angular.module('mychat2', ['ngRoute', 'angularMoment'])
  .run(['$window', '$rootScope', '$location', 'server', function($window, $rootScope, $location, server) {
  moment.locale('zh-cn');
  server.validate().then(function(){
    if($location.path() === '/login'){
      $location.path('/rooms');
    }
  },function(){
    $location.path('/login');
  });

  $rootScope.logout = function() {
    server.logout().then(function(){
      $location.path('/login');
    })
  }
  $rootScope.me = server.getUser();
}]);
